<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../css/mui.min.css" />
		<link rel="stylesheet" type="text/css" href="../css/common.css" />
		<style type="text/css">
			.mui-input-row {
				margin: 10px;
			}
			
			.mui-input-row textarea {
				font-size: 14px;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-back mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">申诉</h1>
		</header>
		<div class="mui-content">
			<div class="mui-input-row">
				<textarea rows="5" id="content" placeholder="申诉内容"></textarea>
			</div>
			<button class="mui-btn btn-main btn-block" data-loading-text = "发布中">确认</button>
		</div>
		<script src="../js/mui.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/common.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/user.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			mui.plusReady(function() {
				var artistId = plus.webview.currentWebview().artistId;
				var artshowId = plus.webview.currentWebview().artshowId;
				var content = document.getElementById("content");
				mui(".mui-content").on('tap', 'button', function() {
					var self = this;
					if(content.value) {
						mui(self).button('loading');
						Common.ajax({
							url : baseURL + 'complain/new/' + artistId + '/' + artshowId + '.json',
							type : 'POST',
							data : 'desc=' + content.value
						}, function(data) {
							mui(self).button('reset');
							console.log(JSON.stringify(data));
							if(data.code == 1) {
								mui.toast('申诉已提交');
								mui.fire(plus.webview.currentWebview().opener(), 'reload');
								mui.back();
							} else {
								mui.toast('操作失败，请稍后重试');
							}
						}, function(xhr) {
							mui(self).button('reset');
							mui.toast('网络异常，请稍后再试');
							console.error('failed - ' + xhr.status + ' : ' + xhr.statusText);
						})
					}
				})
			})
		</script>
	</body>

</html>